<%@ taglib prefix="s" uri="/struts-tags"%>
<%@page contentType="text/html;charset=UTF-8"%>

<script type="text/javascript">
	// URL to call ajax
	var LIST_GROUP_URL   = "<s:url value='/securityList/groupModuleAjax_SearchGroupByCurrentGroup'/>";

	// Action formatter
	function actionFormatter(value,row,index){
		var s = '<a href="#" class="btnlogin" onclick="viewBills(this)">View Bills</a> ';
		return s;
	}
	
	function onLoadSuccess(data) {
	}

	function getRowIndex(target){
		var tr = $(target).closest('tr.datagrid-row');
		return parseInt(tr.attr('datagrid-row-index'));
	}

	function viewBills(target){
		var index = getRowIndex(target);
		var row = $('#dg').datagrid('getRows')[index];
		var groupCode = row.groupCode;
		$("#reportDownload_groupCode").val(groupCode);
		$("#reportDownload").submit();
	}

</script>

<center>
<h2>Bill Download</h2>
</center>

<form id="reportDownload"  method="post" action='<s:url action="/bill/downloadBill"/>' >
	<s:hidden id="reportDownload_groupCode" name="groupInfo.groupCode"/>
</form>
<center>
	<table id="dg" class="easyui-datagrid" style="width:850px;height:auto" title="List Group" fitColumns="true"
			data-options="
				singleSelect: true,
				url: LIST_GROUP_URL,
				loadFilter: function(data) {
					if (data.groupInfoList !== null && data.groupInfoList !== undefined) {
						return {rows: data.groupInfoList, total: data.groupInfoList.length}
					} else {
						return {rows: [], total: 0}
					}					
				},
				method: 'post',
				onLoadSuccess: onLoadSuccess
			">
		<thead>
			<tr>
				<th data-options="field:'groupCode',width:150">Group Code</th>
				<th data-options="field:'groupName',width:250">Group Name</th>
				<th data-options="field:'displayCreatedDate',width:200">Created Date</th>
				<th data-options="field:'action',width:150,align:'center',formatter:actionFormatter">Action</th>
			</tr>
		</thead>
	</table>
</center>